package com.study.test.service.Impl;


import com.study.test.entity.Student;
import com.study.test.mapper.StudentMapper;
import com.study.test.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class StudentServiceImpl implements StudentService {

    private StudentMapper studentMapper;

    @Autowired
    public void setStudentMapper(StudentMapper studentMapper){
        this.studentMapper = studentMapper;
    }

    /**
     * 查询功能
     * @return
     */
    @Override
    public List<Student> findAll(Integer pageNum, Integer pageSize) {
        return studentMapper.findAll(pageNum,pageSize);
    }

    /**
     * 删除功能
     * @param id
     * @return
     */
    @Override
    public boolean deleteStudent(int id) {

        int row = studentMapper.deleteStudent(id);

        if(row > 0){
            return true;
        }
        return false;
    }

    /**
     * 插入功能
     * @param student
     * @return
     */
    @Override
    public boolean insertStudent(Student student) {
        int row = studentMapper.insertStudent(student);
        if(row > 0){
            return true;
        }
        return false;
    }



    /**
     * 修改功能
     * @param student
     * @return
     */
    @Override
    public boolean updateStudent(Student student) {
        int row = studentMapper.updateStudent(student);
        if(row > 0){
            return true;
        }
        return false;
    }

    /**
     * 查询总记录数
     * @return
     */
    @Override
    public Integer findTotalRecord() {
        return studentMapper.findTotalRecord();
    }

}
